Method of processing a digital image

ABSTRACT

Processing of a mosaic digital image includes interpolating values of a first color at pixels where the first color was not sampled. The interpolation of the first color value at a given pixel includes determining likelihoods of the given pixel belonging to the same region as each of at least two other pixels having sampled values of the first color. The other pixels are in different directions relative to the given pixel. The interpolation further includes using the likelihoods and the sampled values of the other pixels to interpolate the first color at the given pixel.

BACKGROUND

A typical digital camera includes an array of photosensors, with each photosensor sensitive to only a single color of light. For example, each photosensor is sensitive to one of red, green and blue light. During image acquisition, an image is focused on the photosensor array, and each photosensor measures or “samples” a single color of the image. If red-sensitive, green-sensitive and blue-sensitive photosensors can be located at each pixel, the photosensor array can acquire an image having “full color” at each pixel.

The photosensor arrays of certain digital cameras have only a single photosensor at each pixel location. These cameras produce digital images that do not have full color information at each pixel. Since each photosensor is sensitive to only a single color, the photosensor array produces a digital image having only a single color sample at each pixel. For example, a digital camera produces a digital image having one of red, green and blue sampled information at each pixel. Information about the other two colors at each pixel is missing. This undersampled digital image is referred to as a “mosaic” image.

A demosaicing algorithm may be used to transform an undersampled digital image into a digital image having full color information at each pixel value. A typical demosaicing algorithm interpolates the missing pixel information from the sampled pixel values in the mosaic image.

Edges and other abrupt photometric transitions present a particular problem to demosaicing. A simple demosaicing algorithm such as bilinear interpolation fills in a missing pixel value by taking an average of sampled values from neighboring pixels. However, some of those neighbors might lie on opposite sides of an edge. Some of the neighbors lying on one side of the edge might belong to one object, while the other neighbors lying on the other side might belong to a different object. Consequently, the interpolated pixel information might not describe either object. Since traditional bilinear interpolation does not account for edges, color information at edges in the demosaiced image can be distorted.

More complex demosaicing algorithms try to account for edges. Still, even the more complex demosaicing algorithm can introduce artifacts into the demosaiced image. Zippering and fringing are typical artifacts at edges in the demosaiced image. These artifacts can degrade image quality.

A typical digital camera can perform the demosaicing. This capability allows a typical digital camera to display and upload images having full color at each pixel. However, memory and processing power of a typical digital camera are limited. The limited memory a nd processing power can constrain the complexity of the demosaicing algorithm and hamper the ability to account for edges and reduce artifacts at the edges during demosaicing.

A demosaicing algorithm that is simple and fast, and that reduces edge blurring and the visibility of certain artifacts at edges, is desirable. Such a demosaicing algorithm is especially desirable for digital cameras.

SUMMARY

According to one aspect of the present invention, processing of a mosaic digital image includes interpolating values of a first color at pixels where the first color was not sampled. The interpolation of the first color value at a given pixel includes determining likelihoods of the given pixel belonging to the same region as each of at least two other pixels having sampled values of the first color. The other pixels are in different directions relative to the given pixel. The interpolation further includes using the likelihoods and the sampled values of the other pixels to interpolate the first color at the given pixel.

Other aspects and advantages of the present invention will become apparent from the following detailed description, taken in conjunction with the accompanying drawings, illustrating by way of example the principles of the present invention.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is an illustration of a photosensor arrangement for a typical digital camera, and corresponding pixels of a mosaic image.

FIG. 2 is an illustration of a method of performing image demosaicing in accordance with an embodiment of the present invention.

FIG. 3 is an illustration of an exemplary pixel neighborhood that can be used to interpolate missing green information at a given pixel in accordance with an embodiment of the present invention.

FIG. 4 is an illustration of a method of interpolating missing green information during demosaicing in accordance with an embodiment of the present invention.

FIG. 5 is an illustration of a first method of interpolating missing red and blue information during demosaicing in accordance with an embodiment of the present invention.

FIG. 6 is an illustration of a second method of interpolating missing red and blue information during demosaicing in accordance with an embodiment of the present invention.

FIG. 7 is an illustration of a third method of interpolating missing red and blue information during demosaicing in accordance with an embodiment of the present invention.

FIG. 8 is an illustration of an apparatus for performing image demosaicing in accordance with an embodiment of the present invention.

FIG. 9 is an illustration of an apparatus for performing image demosaicing in accordance with an embodiment of the present invention.

DETAILED DESCRIPTION

As shown in the drawings for purposes of illustration, the present invention is embodied in the processing of a mosaic image to produce a digital image having full color information at each pixel. Also for the purposes of illustration, the demosaicing will be described in connection with a photosensor arrangement known as a Bayer color filter array (CFA).

Reference is made to FIG. 1, which illustrates a photosensor array 110 having photosensors 112 arranged in a Bayer CFA. The photosensors 112 are arranged in 2×2 cells 114. Each cell 114 consists of two photosensors sensitive to green (G) light only, one photosensor sensitive to red (R) light only, and one photosensor sensitive to blue (B) light only. The cells 114 are repeated (tiled) across the photosensor array 110.

FIG. 1 also illustrates a mosaic digital image 150. Each block 154 of the mosaic image 150 corresponds to a cell 114 of the photosensor array 110. Each pixel 152 of the mosaic image 150 is described by an n-bit word, and each n-bit word provides one of red, green and blue color sampled information. In each 2×2 block 154 of the mosaic image 150, green information is sampled at two pixels, red information is sampled at one pixel, and blue information is sampled at one pixel.

Reference is made to FIG. 2, which illustrates a method of processing a mosaic image into an output image having full color information at each pixel. Each pixel of the output image may be represented by a digital word including n-bits for red information, n-bits for green information, and n-bits for blue information.

The sampled values of the mosaic image are copied into their corresponding positions in the output image (210). For example, a mosaic image with a Bayer pattern has pixel inputs m(i, j), where i and j are indices to the rows and columns of the mosaic image. The sampled values of the mosaic image may be copied to the output image as follows:

-   -   I_(R)(j)=m(i,j) for all red samples (i and j even),     -   I_(G)(j)=m(i,j) for all green samples (i+j odd), and     -   I_(B)(i,j)=m(i,j) for all blue samples (i and j odd),         where I_(R)(i,j) represents red information at pixel (i,j) of         the output image, I_(G)(i,j) represents green information at         pixel (i,j) of the output image, and I_(B)(i,j) represents blue         information at pixel (i,j) of the output image.

The sampled values may be pre-processed (220). The pre-processing is application-specific. In a digital camera for example, pre-processing between image acquisition and demosaicing may include flare reduction, data linearization, color balance, and denoising. Denoising may be performed if the sampled pixel values (that is, the raw data) are noisy or expected to be noisy. Noisy raw data can cause artifacts and noise to appear in the demosaiced image.

Missing information in the green color plane is interpolated (230). For a given pixel that is missing green information, sampled values of nearby pixels are used to determine the likelihoods of the given pixel belonging to the same region as each of its neighbors having sampled green values. These neighbors are in different directions relative to the given pixel. For example, these neighbors might include a first pixel north of the given pixel, a second pixel south of the given pixel, a third pixel east of the given pixel, and a fourth pixel west of the given pixel.

A high likelihood suggests that the missing green value at the given pixel is likely to be close to the sampled value of the neighbor (e.g., an edge between the given pixel and the neighbor is not likely). Therefore, the sampled green value of the neighbor can be used with confidence in the interpolation of the green value at the given pixel. Thus a neighbor having a high likelihood is given a high weight in the interpolation process. Conversely, a low likelihood suggests that the given pixel is likely to be part of a different object than the neighbor (e.g., an edge between the given pixel and the neighbor is likely). Thus a neighbor having a low likelihood is given a low weight in the interpolation process.

The interpolation also includes computing correction terms for each direction. A correction term for a direction may be computed as a difference between the sampled value at the given pixel and a sampled value of the same color at a nearby pixel in that direction.

The interpolation further includes using the likelihoods, the sampled green values of the other pixels, and the correction terms to interpolate the green value at the given pixel. For example, the likelihoods are used to assign weights to the sampled values and the correction terms, and the green value at the given pixel is interpolated as a weighted average of the sampled green values and the correction terms. The interpolated green value is added to the output image.

The use of the weighted correction terms may regarded as a high frequency correction to the interpolated green value. The same likelihood and weight may be used for the same direction. That is, the likelihood and weight computed for a measured green value may also be used for the correction term in the same direction. The meaning of “same direction” will become clear from examples below. In the alternative, likelihoods and weights may be computed separately for the correction terms.

Missing information in the other color planes is interpolated and added to the output image (240). Missing information in each of the red and blue color planes may be interpolated by using weighted averaging in the manner similar to that used to interpolate the missing information in the green color plane. Other methods of interpolating the missing information in each of the red and blue color planes include bilinear interpolation, affine interpolation, and a canonical correlation method, all of which will be described below. At the completion of step 240, each pixel I(i,j) in the output image has red information I_(R)(i,j), green information I_(G)(i,j), and blue information I_(B)(i,j).

Post processing may be performed on the output (demosaiced) image (250). The post-processing is application-specific. In a digital camera for example, the post-processing may include color transformation, tone reproduction, sharpening, and compression.

Reference is now made to FIG. 3, which shows a few pixels of the output image after the sampled values are copied to it, but before any of the missing values are interpolated. The letters R, G and B denote the sampled colors at the pixels. Arrows denote possible directions. The labels N, S, E and W identify these possible directions as north, south, east and west (these directions are figurative, not literal). The north and south directions are orthogonal to the east and west directions.

Additional reference is made to FIG. 4, which illustrates a method of interpolating the missing information in the green color plane. The method may be performed for each pixel that is missing green information in the mosaic image.

By way of example, the method will be described for the pixel that is circled in FIG. 3. The given pixel in FIG. 3 has a sampled red value, but is missing green and blue information. Sampled green values are at pixels to the immediate north, south, east and west of the given pixel.

Sampled green values of the neighboring pixels are used to determine the likelihoods of the given pixel belonging to the same region as each of those neighboring pixels (410). Considering the example of FIG. 3, a first likelihood of the given pixel belonging to the same region as the north neighbor is determined, a second likelihood of the given pixel belonging to the same region as the south neighbor is determined, a third likelihood of the given pixel belonging to the same region as the east neighbor is determined, and a fourth likelihood of the given pixel belonging to the same region as the west neighbor is determined.

Each likelihood may be based on differences of the sampled green values. For example, the first likelihood may be computed from a difference between the sampled green values of the north and south neighbors; the second likelihood may be computed from a difference between the sampled green values of the north and south neighbors; the third likelihood may be computed from a difference between the sampled green values of the east and west neighbors; and the fourth likelihood may be computed from a difference between the sampled green values of the east and west neighbors.

Each likelihood may be also based on differences between the sampled red value of the given pixel and the sampled red value closest to the given pixel in the corresponding direction. For example, the first likelihood term for the north neighbor also may be computed from a difference between the sampled red value of the given pixel and the sampled red value north of the given pixel. The second likelihood term for the south neighbor also may be computed from a difference between the sampled red value of the given pixel and the sampled red value south of the given pixel. The third likelihood term for the east neighbor also may be computed from a difference between the sampled red value of the given pixel and the sampled red value east of the given pixel. The fourth likelihood term for the west neighbor also may be computed from a difference between the sampled red value of the given pixel and the sampled red value west of the given pixel.

The likelihood of a given pixel belonging to the same region as a neighboring pixel may be determined by applying a similarity function to the sum of absolute differences corresponding to that direction. A large absolute difference in sampled values over a short distance (that is, an abrupt transition) is assumed to result from an edge. Thus a large sum of absolute differences in a given direction implies that the given pixel lies on one side of an edge (and belongs to one object), and the neighbor at that direction lies on the other side of the edge (and belongs to a different object): Therefore, a low likelihood exists that the green values of the given pixel and neighbor are similar. Exemplary similarity functions ρ(x) include, but are not limited to, the following: ${\rho(x)} = {\exp\left( \frac{- x^{2}}{\sigma^{2}} \right)}$ ${\rho(x)} = \frac{1}{{x} + 1}$ ${\rho(x)} = {\min\left( {\frac{T}{x},1} \right)}$ ρ(x) = 1/max (x, 1) where T and σ are scaling parameters that account for the expected noise level in the raw data. The input x corresponds to a sum of absolute differences.

Correction terms are also computed (420). A first correction term for the north neighbor may be computed as a difference between the sampled red value of the given pixel and the sampled red value north of the given pixel. A second correction term for the south neighbor may be computed as a difference between the sampled red value of the given pixel and the sampled red value south of the given pixel. A third correction term for the east neighbor may be computed as a difference between the sampled red value of the given pixel and the sampled red value east of the given pixel. A fourth correction term for the west neighbor may be computed as a difference between the sampled red value of the given pixel and the sampled red value west of the given pixel.

The likelihoods, the sampled pixel values, and the correction terms are used to interpolate the missing green value at the given pixel (430). For example, the missing green pixel value (I_(G)) at a given pixel (i,j) may be computed as follows: ${I_{G}\left( {i,j} \right)} = \frac{\sum\limits_{{({a,b})} \in N_{4}}\begin{matrix} \left\{ {{\lambda\left\lbrack {{m\left( {i,j} \right)} - {m\left( {{i + {2a}},{j + {2b}}} \right)}} \right\rbrack} +} \right. \\ {\left. {m\left( {{i + a},{j + b}} \right)} \right\}{w_{a,b}\left( {i,j} \right)}} \end{matrix}}{\sum\limits_{{({a,b})} \in N_{4}}{w_{a,b}\left( {i,j} \right)}}$ where N₄ is the neighborhood consisting of the four sampled green values. The index (a,b) indicates the direction and number of pixels relative to the given pixel. For example, the neighborhood N₄ may consist of {(−1,0), (1,0), (0,−1) and (0,1)}, which are the nearest pixels due west (−1,0), due east (1,0), due south (0,−1) and due north (0,1) of the given pixel. The above formula holds only for those pixels (i,j) that correspond to non-green positions in the mosaic image.

The bracketed term [m(i,j)−m(i+2a,j+2b)] represents the correction term for sampled green value at the neighbor (a, b), and the term m(i+a, j+b) represents the sampled green value at the neighbor (a, b).

The parameter λ is a tunable parameter that corrects the interpolated value for camera-specific items, such as image resolution, camera optics, and scene distance. If device resolution is small or edges are too abrupt, the parameter λ may have a value between 0.5 and 1. For mid-resolution cameras, the parameter λ may have a value of 0.5. For high resolution cameras, the parameter λ may have a value of less than 0.5.

The weights w_(a,b) may be computed as w _(a,b)(i,j)

ρ[|m(i+2a, j+2b)−m(i,j)|+|m(i+a, j+b)−m(i−a, j−b)|] The first absolute difference |m(i+a,j+b)−m(i+a,j+b)| represents the differences in the green color plane, and the second absolute difference |m(i+2a,j+2b)−m(i,j)| represents the difference in the red color plane.

The method is not limited to a Bayer CFA. The method may be applied to other color filter arrays.

The method is not limited to the N, S, E and W directions, or the four closest neighbors. Larger neighborhoods may be used, and pixels of different distances may be used. Weights may be reduced as distance increases.

Various methods may be used to interpolate the missing information in the red and blue color planes. One such method is bilinear interpolation of corrected values. In bilinear interpolation, likelihoods are not computed, and all weights are the same. The interpolation may be based on a smaller neighborhood because correction terms can now be computed entirely from the green plane, which is now fully populated. Therefore, differences may be taken from adjacent green pixels, as opposed to differences taken from samples that are two pixels apart (which occurs during interpolation of the green plane). The following formula may be used to interpolate a missing red or blue color I_(C)(i,j) at pixel (i,j), given the fully populated green plane I_(G): ${I_{c}\left( {i,j} \right)} = {{\frac{1}{N_{G,c}^{({i,j})}}{\sum\limits_{{({a,b})} \in N_{G,c}^{({i,j})}}^{\quad}\quad{I_{G}\left( {i,j} \right)}}} - {I_{G}\left( {{i + a},{j + b}} \right)} + {m\left( {{i + a},{j + b}} \right)}}$ where  c ∈ {R, B}, and $N_{G,c}^{({i,j})}\left\{ \begin{matrix} {\left\{ {\left( {{- 1},0} \right),\left( {1,0} \right)} \right\},} & \begin{matrix} {{c = R},{i\quad{is}\quad{odd}},{j\quad{is}\quad{even}},{or}} \\ {{{c = B},{i\quad{is}\quad{even}},{j\quad{is}\quad{odd}}}\quad} \end{matrix} \\ {\left\{ {\left( {0,{- 1}} \right),\left( {0,1} \right)} \right\},} & \begin{matrix} {{c = B},{i\quad{is}\quad{odd}},{j\quad{is}\quad{even}},{or}} \\ {{{c = R},{i\quad{is}\quad{even}},{j\quad{is}\quad{odd}}}\quad} \end{matrix} \\ \begin{matrix} {\left\{ {\left( {{- 1},{- 1}} \right),\left( {{- 1},1} \right)} \right\},} \\ {\left\{ {\left( {1,{- 1}} \right),\left( {1,1} \right)} \right\},} \end{matrix} & \begin{matrix} {{c = R},{i\quad{is}\quad{odd}},{j\quad{is}\quad{odd}},{or}} \\ {{{c = B},{i\quad{is}\quad{even}},{j\quad{is}\quad{even}}}\quad} \end{matrix} \end{matrix} \right.$

FIGS. 5-7 illustrate other methods of interpolating the missing information in the red and blue color planes. Reference is now made to FIG. 5, which illustrates a method that is essentially the same as the method used to interpolate the missing green information. The nearest sampled red or blue value in each direction is two pixels from the given pixel. At step 510, the likelihoods are determined from the green plane only. In addition, the correction terms are determined from the green plane (step 520). At step 530, the following formula may be used to interpolate a missing color I_(C)(i,j) at pixel (i,j): ${I_{c}\left( {i,j} \right)} = \frac{\sum\limits_{{({a,b})} \in N_{G,c}^{({i,j})}}^{\quad}\quad{\left\lbrack {{I_{G}\left( {i,j} \right)} - {I_{G}\left( {{i + a},{j + b}} \right)} + {m\left( {{i + a},{j + b}} \right)}} \right\rbrack{u_{a,b}\left( {i,j} \right)}}}{\sum\limits_{{({a,b})} \in N_{G,c}^{({i,j})}}^{\quad}{u_{a,b}\left( {i,j} \right)}}$ where  c ∈ {R, B}, and $N_{G,c}^{({i,j})}\left\{ {{\begin{matrix} {\left\{ {\left( {{- 1},0} \right),\left( {1,0} \right)} \right\},} & \begin{matrix} {{c = R},{i\quad{is}\quad{odd}},{j\quad{is}\quad{even}},{or}} \\ {{{c = B},{i\quad{is}\quad{even}},{j\quad{is}\quad{odd}}}\quad} \end{matrix} \\ {\left\{ {\left( {0,{- 1}} \right),\left( {0,1} \right)} \right\},} & \begin{matrix} {{c = B},{i\quad{is}\quad{odd}},{j\quad{is}\quad{even}},{or}} \\ {{{c = R},{i\quad{is}\quad{even}},{j\quad{is}\quad{odd}}}\quad} \end{matrix} \\ \begin{matrix} {\left\{ {\left( {{- 1},{- 1}} \right),\left( {{- 1},1} \right)} \right\},} \\ {\left\{ {\left( {1,{- 1}} \right),\left( {1,1} \right)} \right\},} \end{matrix} & \begin{matrix} {{c = R},{i\quad{is}\quad{odd}},{j\quad{is}\quad{odd}},{or}} \\ {{{c = B},{i\quad{is}\quad{even}},{j\quad{is}\quad{even}}}\quad} \end{matrix} \end{matrix}{and}{u_{a,b}\left( {i,j} \right)}}\overset{\Delta}{=}{{\rho\left\lbrack {{{I_{G}\left( {i,j} \right)} - {I_{G}\left( {{i + a},{j + b}} \right)}}} \right\rbrack}.}} \right.$

Reference is now made to FIG. 6, which illustrates a canonical correlation method of interpolating the missing red and blue information. An initial estimate for the missing values is made (610). For instance, the initial estimate may be made by using standard bilinear demosaicing. These initial estimates are added to the output image. Thus, at the end of step 610, the output image includes sampled and interpolated values for the green plane, and sampled and estimated values for the red and blue planes.

The output image is transformed into a luminance-chrominance color space (620). For example, the output image may be transformed into YIQ color space.

The chrominance bands of the YIQ color space are strongly smoothed (630). The luminance band may be lightly smoothed; left unchanged, or even lightly sharpened (630). According to the principles achieved by canonical correlation analysis, natural images are expected to be smooth in chrominance bands, whereas all sharpness that the human eye perceives is expected to stem from the luminance band only. In terms of frequencies, light smoothing would be less aggressive in reducing high-frequencies of an image, as compared to the strong smoothing.

The output image is transformed back to its original color space (640), and reset to the sampled values and green interpolated values (650). Step 650 imposes a constraint on the interpolation. After filtering in the YIQ domain, the sampled values in the green plane of the output image are likely to change from their original values. The previously calculated green plane is likely to have changed as well. Imposing the constraints or resetting the sampled and green interpolated values is performed to replace the output green plane by the previously calculated green plane, and to reset the original red and blue mosaic samples on their corresponding positions.

Steps 620 to 650 may be repeated several times. The steps 620 to 650 may converge to an optimal result. The iterations can be stopped when the result is “close enough” to the optimum. For example, the iterations can be stopped when the improvement (Euclidean distance between the image before and after an iteration) becomes smaller than a threshold. In the alternative, a fixed number of iterations can be performed. The fixed number would typically bring the output close enough to the optimum.

Provided that the smoothing is linear, a fixed number of iterations can be concatenated into a single linear operation to provide a set of twelve linear convolution kernels. A set of kernels can be convolved with the pixel values of each cell.

Reference is now made to FIG. 7, which illustrates affine interpolation of the missing red and blue information. The following formula may be used to interpolate a missing color I_(c)(i,j) at pixel (i,j): I _(d)(x,y)=t _(d,c)(x,y)I _(c)(x,y)+s _(d,c)(x,y) where d,c∈{R,G,B}, s_(d,c) is a slowly varying function of a shift in color c, and t_(d,c) is a slowly varying function that scales the intensity gradient.

The function s_(d,c) is based on the assumption that object boundaries in a small spatial neighborhood are the same in all three color planes, or that the high frequency components (edges depicting object boundaries) in a small spatial neighborhood are similar in all three planes and equal with the high frequency component of the green plane.

The function t_(d,c) is based on the assumption that an edge in a color plane can vary by a different amount than the same edge in another color plane.

The functions s_(d,c) and t_(d,c) can be solved for from the green plane. Consider a pixel (i₀,j₀) having missing red information. Red information I_(R)(i_(q),j_(q)) and green information I_(G)(i_(q),j_(q)) are known at neighboring pixels (i_(q),j_(q)), q=1, . . . ,k, where either i₀ or j₀ are odd, where i_(q) and j_(q) are even, and where (i_(q),j_(q))∈N(i₀,j₀). The following set of equations is obtained. {I _(R)(i _(q) ,j _(q))=t _(R,G)(i ₀ ,j ₀)I _(G)(i _(q) ,j _(q))+S _(R,G)(i ₀ ,j ₀)}_(q=1) ^(k).

These inequalities can be rewritten in matrix form: ${\begin{pmatrix} {I_{G}\left( {i_{1}.j_{1}} \right)} & 1 \\ {I_{G}\left( {i_{2},j_{2}} \right)} & 1 \\ \vdots & \vdots \\ {I_{G}\left( {i_{k},j_{k}} \right)} & 1 \end{pmatrix}\begin{pmatrix} {t_{R,G}\left( {i_{0},j_{0}} \right)} \\ {s_{R,G}\left( {i_{0},j_{0}} \right)} \end{pmatrix}} = \begin{pmatrix} {I_{R}\left( {i_{1}.j_{1}} \right)} \\ {I_{R}\left( {i_{2},j_{2}} \right)} \\ \vdots \\ {I_{R}\left( {i_{k},j_{k}} \right)} \end{pmatrix}$

A Mean Least Squares solution gives the following ${{\hat{t}}_{R,G}\left( {i_{0},j_{0}} \right)} = \frac{{E\left\{ {I_{G}I_{R}} \right\}\left( {i_{0},j_{0}} \right)} - {E\left\{ I_{G} \right\}\left( {i_{0},j_{0}} \right)E\left\{ I_{R} \right\}\left( {i_{0},j_{0}} \right)}}{{E\left\{ I_{G}^{2} \right\}\left( {i_{0},j_{0}} \right)} - {E^{2}\left\{ I_{G} \right\}\left( {i_{0},j_{0}} \right)}}$ and Ŝ _(R,G)(i ₀ ,j ₀)=E{I _(R)}(i ₀ ,j ₀)−{circumflex over (t)} _(R,G)(i ₀ ,j ₀)E{I _(G)}(i ₀ ,j _(o))E{I _(G)}(i ₀,j₀) where ${E\left\{ f \right\}\left( {i_{0},j_{0}} \right)} = {\frac{1}{k}{\sum\limits_{({i_{q},j_{q}})}{f\left( {i_{q},j_{q}} \right)}}}$ for (i_(q),j_(q))∈N(i₀,j₀) where i_(q) and j_(q) are even.

Neighborhood size is based on assumptions about how quickly t_(d,c) and s_(d,c) change. A 5×5 neighborhood has been found to provide a reasonable tradeoff of accuracy versus stability. Increasing the neighborhood size can improve the accuracy, but decrease the stability, since there is a greater chance that t_(d,c) and s_(d,c) will not remain constant.

The operator E{ } may be regarded as a simple averaging of neighborhood. The following equation, which can be used instead, produces a weighted average. ${E\left\{ f \right\}\left( {i_{0},j_{0}} \right)} = {\frac{1}{k}\frac{\sum\limits_{({i_{q},j_{q}})}{{f\left( {i_{q},j_{q}} \right)}{u_{q}\left( {i_{0},j_{0}} \right)}}}{\sum\limits_{({i_{q},j_{q}})}{u_{q}\left( {i_{0},j_{0}} \right)}}}$ where u_(q)(i₀,j₀)=ρ(|I_(G)(i₀,j₀)−I_(G)(i_(q),j_(q))|)

Reference is made to FIG. 8, which illustrates an exemplary hardware implementation of the methods above. A digital camera 810 includes a photosensor array 812 such as a CCD. The photosensors of the array 812 may be arranged in a Bayer CFA. The array 812 produces mosaic digital images.

The digital camera 810 also includes a digital signal processor 814 and memory 816 (e.g., EPROM). A program 818 encoded in the memory 816 instructs the digital signal processor 814 to transform mosaic images into digital images having full color information at each pixel in accordance with an embodiment of the present invention. The program 818 may include a lookup table for different values of the similarity function. Weights are computed on the fly, and applied to the pixels using an algorithm.

Another implementation (not shown) may include an application-specific integrated circuit (ASIC). The ASIC includes a processor for transforming mosaic images into digital images having full color information at each pixel in accordance with an embodiment of the present invention. The processor may include a state machine, or it may include an embedded processor and memory, or it may have some other design.

Reference is now made to FIG. 9, which illustrates another hardware implementation. A digital imaging system 910 includes a general purpose processor 912 and memory 914 for instructing the processor 912 to process mosaic images in accordance with an embodiment of the present invention. The system may be, for example, a personal computer. Mosaic images may be supplied to the system 910 directly by a capture device (e.g., a scanner, a digital camera) or indirectly (via the Internet, accessed from remote or local storage, etc.).

A machine for generating the program may be a personal computer such as the one shown in FIG. 9. Source code is generated, compiled into executable code, and distributed.

The executable code may be distributed in variety of ways. For example, the executable code may be distributed to a digital camera by burning the code into an EPROM of the digital camera. The executable code can be distributed to a computer via a network transmission, removable storage medium (e.g., CD), etc.

The present invention is not limited to the specific embodiments described above. Instead, the present invention is construed according to the following claims. 

1. A method of processing a digital image, each pixel of the digital image having only a single sampled value, the method comprising interpolating values of a first color at pixels where the first color was not sampled, the interpolation of the first color value at a given pixel including: determining likelihoods of the given pixel belonging to the same region as each of at least two other pixels having sampled values of the first color, the other pixels in different directions relative to the given pixel; and using the likelihoods and the sampled values of the other pixels to interpolate the first color at the given pixel.
 2. The method of claim 1, wherein at least two of the directions are orthogonal.
 3. The method of claim 1, wherein the directions include north, south, east and west of the given pixel.
 4. The method of claim 1, wherein the sampled pixel values are of neighboring pixels nearest the given pixel.
 5. The method of claim 1, further comprising additionally using sampled values of a second color to compute terms for correcting the sampled values of the first color.
 6. The method of claim 5, wherein using the sampled values of the second color to correct a sampled value of the first color includes taking a difference between the sampled value at the given pixel and the sampled value of the second color at a neighbor, the neighbor lying in the same direction as the pixel being corrected.
 7. The method of claim 6, wherein the likelihoods are used to compute a weighted average of the sampled values and correction terms.
 8. The method of claim 1, wherein determining the likelihoods includes applying a similarity function to differences between sampled values.
 9. The method of claim 8, wherein determining the likelihoods includes using the differences to index a lookup table of precomputed likelihoods.
 10. The method of claim 1, wherein the likelihoods are used to compute a weighted average of the sampled values.
 11. The method of claim 1, wherein the first color is green, whereby missing information in a green color plane is interpolated.
 12. The method of claim 11, wherein missing green information (I_(G)) at a given pixel (i,j) is computed as ${I_{G}\left( {i,j} \right)} = {\frac{\begin{matrix} {\sum\limits_{{({a,b})} \in N}^{\quad}\left\{ {{\lambda\left\lbrack {{m\left( {i,j} \right)} - {m\left( {{i + {2a}},{j + {2b}}} \right)}} \right\rbrack} +} \right.} \\ {\left. {m\left( {{i + 2},{j + b}} \right)} \right\}{w_{a,b}\left( {i,j} \right)}} \end{matrix}}{\sum\limits_{{({a,b})} \in N}^{\quad}{w_{a,b}\left( {i,j} \right)}}.}$ where m(i,j) is a sampled pixel value, a and b are components of a vector (a,b), λ is a tunable parameter, N is a neighborhood of pixels, and w_(a,b) are weights corresponding to the vector (a,b).
 13. The method of claim 12, wherein the weights w_(a,b) are computed as w_(a,b)(i,j)

ρ[|m(i+2a, j+2b)−m(i,j)|+|m(i+a,j+b)−m(i−a,j−b)|], where ρ[•] is a similarity function.
 14. The method of claim 1, wherein the digital image corresponds to a Bayer CFA.
 15. The method of claim 1, further comprising interpolating at least one other color at each pixel.
 16. The method of claim 15, wherein the likelihoods are used to interpolate missing information in one color plane, and wherein bilinear interpolation is used to interpolate missing information in other color planes, wherein the interpolation includes using sampled and interpolated green pixel values.
 17. The method of claim 15, further comprising interpolating additional missing values, the interpolation of a second color value at the given including: using sampled and interpolated first color values to determine likelihoods of the given pixel belonging to the same region as neighboring pixels; and using the likelihoods and sampled second color values in the neighborhood to interpolate the second color value at the given pixel.
 18. The method of claim 17, further comprising computing correction terms; and using the correction terms to correct the sampled second color values in the neighborhood.
 19. The method of claim 18, wherein a missing color value I_(c)(i,j) at pixel (i,j) is computed as ${I_{c}\left( {i,j} \right)} = \frac{\sum\limits_{{({a,b})} \in N_{G,c}^{({i,j})}}^{\quad}\quad{\left\lbrack {{I_{G}\left( {i,j} \right)} - {I_{G}\left( {{i + a},{j + b}} \right)} + {m\left( {{i + a},{j + b}} \right)}} \right\rbrack{u_{a,b}\left( {i,j} \right)}}}{\sum\limits_{{({a,b})} \in N_{G,c}^{({i,j})}}^{\quad}{u_{a,b}\left( {i,j} \right)}}$ where  c ∈ {R, B}, and $N_{G,c}^{({i,j})}\left\{ {{\begin{matrix} {\left\{ {\left( {{- 1},0} \right),\left( {1,0} \right)} \right\},} & \begin{matrix} {{c = R},{i\quad{is}\quad{odd}},{j\quad{is}\quad{even}},{or}} \\ {{{c = B},{i\quad{is}\quad{even}},{j\quad{is}\quad{odd}}}\quad} \end{matrix} \\ {\left\{ {\left( {0,{- 1}} \right),\left( {0,1} \right)} \right\},} & \begin{matrix} {{c = B},{i\quad{is}\quad{odd}},{j\quad{is}\quad{even}},{or}} \\ {{{c = R},{i\quad{is}\quad{even}},{j\quad{is}\quad{odd}}}\quad} \end{matrix} \\ \begin{matrix} {\left\{ {\left( {{- 1},{- 1}} \right),\left( {{- 1},1} \right)} \right\},} \\ {\left\{ {\left( {1,{- 1}} \right),\left( {1,1} \right)} \right\},} \end{matrix} & \begin{matrix} {{c = R},{i\quad{is}\quad{odd}},{j\quad{is}\quad{odd}},{or}} \\ {{{c = B},{i\quad{is}\quad{even}},{j\quad{is}\quad{even}}}\quad} \end{matrix} \end{matrix}{and}{u_{a,b}\left( {i,j} \right)}}\overset{\Delta}{=}{{\rho\left\lbrack {{{I_{G}\left( {i,j} \right)} - {I_{G}\left( {{i + a},{j + b}} \right)}}} \right\rbrack}.}} \right.$
 20. The method of claim 15, wherein interpolating at least one of the other missing colors includes: making an initial estimate for the other missing colors; transforming an output image into a luminance-chrominance color space, the output image including sampled and interpolated values of the fist color, and sampled values of the other colors; smoothing the luminance and chrominance bands; transforming the output image back to its original color space; and resetting measured values and green interpolated values in the output image
 21. The method of claim 20, wherein each step is a linear operation, and wherein the steps are performed by applying a concatenation of the linear operations to the demosaic image.
 22. The method of claim 15, wherein affine interpolation of at least one of the other colors is performed as I _(d)(x,y)=t _(d,c)(x,y)I _(c)(x,y)+s _(d,c)(x,y) where I_(d) is the color to be interpolated at pixel coordinates (x,y), I_(c) is either the green sampled value or the green interpolated value, s_(d,c) is a slowly varying function of a shift in color c, and t_(d,c) is a slowly varying function that can change the intensity gradient.
 23. Apparatus comprising a processor for interpolating missing values in a first color plane of a mosaic image, the interpolation of a given pixel in the color plane including: determining likelihoods of neighbors belonging to the same region as the given pixel, the neighbors having sampled values of the first color, at least two of the neighbors lying in different directions relative to the given pixel; and using the likelihoods and the sampled values to interpolate a first color value for the given pixel.
 24. The apparatus of claim 23, wherein the processor also uses sampled values in a second color plane to compute correction terms for the sampled values in the first color plane.
 25. The apparatus of claim 24, wherein using the sampled values in the second color plane includes taking a difference between the sampled value at the given pixel and a sampled value in the second color plane at a neighbor, the neighbor lying in the same direction as the sampled value being corrected.
 26. The apparatus of claim 25, wherein the likelihoods are used to compute a weighted average of the sampled values and the correction terms.
 27. The apparatus of claim 23, wherein determining the likelihoods includes applying a similarity function to differences between sampled values.
 28. The apparatus of claim 23, wherein the first color is green, whereby missing information in a green color plane is interpolated.
 29. The apparatus of claim 23, wherein the processor also interpolates at least one other missing color value at each pixel.
 30. The apparatus of claim 23, wherein the processor further interpolates a second color plane, the interpolation of a second color value at the given pixel including: using sampled and interpolated first color values to determine likelihoods of the given pixel belonging to the same region as neighboring pixels; and using the likelihoods and sampled second color values in the neighborhood to interpolate the second color value at the given pixel.
 31. The apparatus of claim 23, wherein the processor further interpolates additional color planes, the interpolation of the additional color planes including: making an initial estimate for missing information in the additional color planes; transforming an output image into a luminance-chrominance color space, the output image including sampled and interpolated values of the fist color, and sampled values of the other colors; smoothing the luminance and chrominance bands; transforming the output image back to its original color space; and resetting measured values and green interpolated values in the output image.
 32. The apparatus of claim 23, wherein the processor further interpolates a second color plane, the interpolation of a second color value at the given pixel at pixel coordinates (x,y) performed according to: I _(d)(x,y)=t _(d,c)(x,y)I _(c)(x,y)+s_(d,c)(x,y) where I_(d) is the second color value, I_(c) is either the green sampled value or the green interpolated value at pixel coordinates (x,y), s_(d,c) is a slowly varying function of a shift in color c, and t_(d,c) is a slowly varying function that can change the intensity gradient.
 33. Apparatus for processing a mosaic image, the apparatus comprising: means for using sampled values in a color plane of the mosaic image to determine the likelihoods of a given pixel belong to the same region as at least two different neighbors lying in different directions; and means for using the likelihoods and sampled values in the different directions to interpolate a value at the given pixel, the interpolated value being in the color plane.
 34. The apparatus of claim 33, further comprising means for aquiring the mosaic image.
 35. A digital camera comprising: a photosensor array for acquiring mosaic images; and a digital signal processor for processing the mosaic images, the processing including interpolating missing values from sampled values in the mosaic image, the interpolation of a given pixel in a given color plane including determining the likelihoods of neighbors belonging to the same region as the given pixel, the neighbors being in at least two different directions relative to the given pixel; and using the likelihoods and the sampled values of the neighbors to interpolate the given color at the given pixel.
 36. The digital camera of claim 35, wherein the processing includes using sampled values of a second color to compute terms for correcting the sampled values of the given color.
 37. An article for instructing a processor to process a mosaic image, the article comprising memory encoded with instructions for instructing the processor to interpolate missing values of a first color, the interpolation of the first color of a given pixel including determining likelihoods of neighbors having sampled values of the first color being in the same region as the given pixel, and using the sampled values and the likelihoods of those neighbors to interpolate the first color at the given pixel, at least one neighbor being in a first direction relative to the given pixel, at least one neighbor being in a second direction relative to the given pixel, where the first and second directions are orthogonal.
 38. The article of claim 37, wherein the processing includes using sampled values of a second color to compute terms for correcting the sampled values of the first color. 